<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function calculateNetIncome(income) {
        let tax = 0;
        // 税率区间和相应的收入范围
        if (income > 10000) {
          tax += (income - 10000) * 0.2;
          income = 10000;
        }
        if (income > 6000) {
          tax += (income - 6000) * 0.08;
          income = 6000;
        }
        if (income > 4000) {
          tax += (income - 4000) * 0.05;
          income = 4000;
        }
        if (income > 2000) {
          tax += (income - 2000) * 0.03;
        }

        return income - tax;
      }
      const money = 8000;
      const netIncome = calculateNetIncome(money);
      console.log(`税后: ${netIncome}`);
    </script>
  </body>
</html>
